package cn.sky.demo.repository;



import cn.sky.demo.domain.entity.ReminderTask;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;

public class ReminderTaskRowMapper implements RowMapper<ReminderTask>{
    
    @Override
    public ReminderTask mapRow(ResultSet rs, int rowNum) throws SQLException {
        ReminderTask task = new ReminderTask();
        task.setId(rs.getLong("id"));
        task.setUserId(rs.getLong("user_id"));
        task.setPhone(rs.getString("phone"));
        task.setMessage(rs.getString("message"));
        task.setStartDate(rs.getObject("start_date", LocalDate.class));
        task.setNextRemindDate(rs.getObject("next_remind_date", LocalDate.class));
        task.setIntervalDays(rs.getInt("interval_days"));
        task.setActive(rs.getBoolean("is_active"));
        // 如果有updatedTime字段也可以设置
        // task.setUpdatedTime(rs.getTimestamp("updated_time"));
        return task;
    }
}